from django.contrib import admin
from courese.models import Subject, Course, Module
# Register your models here.


@admin.register(Subject)
class SubjectAdmin(admin.ModelAdmin):
    list_display = ['title', 'slug']
    prepopulated_fields = {'slug': ('title',)}


class ModuleInline(admin.StackedInline):
    model = Module
@admin.register(Course)



class CourseAdmin(admin.ModelAdmin):
    list_display = ['title', 'subject', 'created']
    list_filter = ['created', 'subject']
    search_fields = ['title', 'overview']
    prepopulated_fields = {'slug': ('title',)}
    inlines = [ModuleInline]


"""
课程应用的模型现在已经在管理平台中注册。我们使
用@admin.register()装饰器替代了admin.site.register()方法。它们
都提供了相同的功能。
"""